export function dealFormatDate(monthIndex) {
  let date = new Date();
  let month = date.getMonth() + 1 + monthIndex;
  let year = date.getFullYear()
  if(month > 12) {
    year = year + parseInt(month/12)
    month = month%12
  }
  let strDate = date.getDate()-1;
  if (month >= 1 && month <= 9) {
    month = "0" + month;
  }
  if (strDate >= 0 && strDate <= 9) {
    strDate = "0" + strDate;
  }
  let hour = date.getHours()
  let minutes = date.getMinutes()
  let second = date.getSeconds()
  if(hour >= 0 && hour <= 9) {
    hour = '0' + hour
  }
  if(minutes >= 0 && minutes <=9 ) {
    minutes = '0' + minutes
  }
  if(second >= 0 && second <= 9) {
    second = '0' + second
  }
  let currentDate = year + "-" + month + "-" + strDate
    + " " + hour + ":" + minutes + ":" + second;
  return currentDate;
}

export function continueSuspentTime(deadline, continueDays) {
  let year = 0
  let month = 0
  let strDate = 0
  if(deadline.split(' ')[0]){
    month = parseInt(deadline.split(' ')[0].split('-')[1]) + continueDays;
    year = parseInt(deadline.split(' ')[0].split('-')[0]);
    strDate = parseInt(deadline.split(' ')[0].split('-')[2])-1;
    if(month > 12) {
      year = year + parseInt(month/12)
      month = month%12
    }
    if (month >= 1 && month <= 9) {
      month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
      strDate = "0" + strDate;
    }
  }
  let currentDate = year + "-" + month + "-" + strDate
    + " " + deadline.split(' ')[1];
  return currentDate;
}
